import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

Widget mCard(double width, String imagePath, String text0, String text1) {
  final currentColor = Colors.white70;//统一卡片与边框的颜色
  final textWidth = width - 25*2 - 120 - 20 - 60;

  return Container(
    height: 120,
    alignment: Alignment.center,
    decoration: BoxDecoration(
      //背景色
      color: currentColor,
      //设置四周圆角 角度
      borderRadius: BorderRadius.all(Radius.circular(15.0)),
      //设置四周边框
      border: new Border.all(width: 0, color: currentColor),
      //实现周围阴影
      boxShadow: [
        BoxShadow(
            color: Colors.black12,
            offset: Offset(5.0, 5.0), //阴影x轴偏移量
            blurRadius: 10, //阴影模糊程度
            spreadRadius: 1 //阴影扩散程度
        )
      ],
    ),
    child: Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        ClipRRect(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(15.0),
              bottomLeft: Radius.circular(15.0)
          ),
          child: Image.asset(imagePath),
        ),
        SizedBox(width: 20,),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: EdgeInsets.only(top: 20),
              child:Container(
                width: textWidth,
                child:Text(
                  text0,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis, //在写死container宽度的基础上设置字符过长时显示省略号
                  style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold),
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 10),
              child: Container(
                width: textWidth,
                child: Text(
                  text1,
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(fontSize: 14,),
                ),
              ),
            ),
          ],
        ),
      ],
    ),
  );
}
